<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<f:view>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
	<html>
	<head>
	<title>IAP cursos</title>
	<script type="text/javascript">
	 function selecionaAula(id, dia){
           document.getElementById("formularioHor:formularioHor:dia").innerHTML = dia;
           document.getElementById("formularioHor:formularioHor:idHorario").value = id;
     }
	</script>
	<link rel="stylesheet" href="../css/template.css" type="text/css">
	</head>
	<body>
	<div id="bg-top">
		<div id="dados_usuarios">
			<h:form>
				<h:commandLink action="#{logOutPageBean.sair}" value="Sair"/>
			</h:form>
		</div>
	<div id="top">
	<div id="logo-banner-admin">
	<div id="logo"></div>
	<div id="banner"></div>
	</div>
	</div>
	</div>
	<div id="bg-main">
	<div id="menu-horiz-top">
	<ul>
		<li><a href="#">In&iacute;cio</a></li>
		<li><a href="#">Professores</a></li>
		<li><a href="#">Espa&ccedil;o do aluno</a></li>
		<li><a href="#">Fala aprovado</a></li>
		<li><a href="#">Downloads</a></li>
		<li><a href="#">Eventos</a></li>
		<li><a href="#">Contato</a></li>
	</ul>
	</div>
	<div id="main">
	<div id="inner-main">

	<div id="conteudo"><h:messages /> <h:form id="formularioHor">
		<c:set var="cont" value="${0}"></c:set>
		<div id="table_edicao_horarios">

			<rich:dataTable headerClass="head_tabela" border="0"
							rowClasses="linha1,linha2" var="horario" id="tabela_horarios"
							value="#{controleHorarios.turmaSelecionada.horarios}"
							>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Horário" />
				</f:facet>
				<h:outputText value="#{horario}" />
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Domingo" />
				</f:facet>

				<h:outputLabel value="#{horario.aulaE.disciplina.nome}" onclick="selecionaAula(#{horario.aulaE.id},'Domingo');" />


				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Segunda" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Segunda');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Terca" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Terça');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Quarta" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Quarta');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Quinta" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Quinta');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Sexta" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Sexta');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

			<rich:column>
				<f:facet name="header">
					<h:outputText value="Sabado" />
				</f:facet>

				<h:inputHidden id="idAula${cont}" value="#{horario.aulaE.id}" />

				<h:outputLabel value="#{horario.aulaE.disciplina}" onclick="selecionaAula(#{horario.aulaE.id},'Sábado');"/>
				<c:set var="cont" value="${cont + 1}"></c:set>
			</rich:column>

		</rich:dataTable></div>

		<h:inputHidden id="total" value="3" />

		<br />

		<div>
		  <h:form id="formularioHor">

		  <h:outputText id="dia" value=""></h:outputText>

		  <h:inputHidden id="idHorario" value="#{controleAtualizarHorarios.idhorario}" />

		  <h:selectOneMenu id="idDisciplina" value="#{controleAtualizarHorarios.iddisciplina}">
              <f:convertNumber type="number" />
              <f:selectItem itemValue="" itemLabel="Sem Aula" />
              <t:selectItems value="#{controleAtualizarHorarios.disciplinas}"
                  var="d" itemLabel="#{d.nome}" itemValue="#{d.id}" />
          </h:selectOneMenu>

          <h:selectOneMenu id="idProfessor" value="#{controleAtualizarHorarios.idprofessor}">
              <f:convertNumber type="number" />
              <f:selectItem itemValue="" itemLabel="---" />
              <t:selectItems value="#{controleAtualizarHorarios.professores}"
                  var="d" itemLabel="#{d.nome}" itemValue="#{d.id}" />
          </h:selectOneMenu>

          </h:form>
		</div>

		<h:commandButton action="#{controleAtualizarHorarios.atualizarHorarios}" value="Alterar horário">

		</h:commandButton>
	</h:form></div>
	</div>
	</div>
	</div>
	</body>
	</html>
</f:view>
